using Webshop20.Domain.Shared.Products.Core;

namespace Webshop20.AntiCorruptionLayers.Lucene
{
    public class ProductFullTextIndexingService : IProductFullTextIndexingService
    {
        private IDocumentTranslator documentTranslator;
        private IIndexerFacade indexerFacade;

        public ProductFullTextIndexingService(IDocumentTranslator documentTranslator, IIndexerFacade indexerFacade)
        {
            this.documentTranslator = documentTranslator;
            this.indexerFacade = indexerFacade;
        }

        public void AddToIndex(Product product)
        {
            var document = documentTranslator.ConvertToDocument(product);
            indexerFacade.AddDocumentToIndex(document);
        }

        public void RemoveFromIndex(Product product)
        {
            var document = documentTranslator.ConvertToDocument(product);
            indexerFacade.RemoveDocumentFromFacade(document);
        }
    }
 
}